<template>
  <div class="mod-config">
    <basic-container>
      <navigation :sign="{ a: true, b: false, c: false }"></navigation>
      <div class="boxsty zhiBiao">
        <div class="flex justifyContentSpaceBetween">
          <div class="tabletext">指标考核创建</div>
        </div>
        <el-form
          :inline="true"
          :model="query"
          @keyup.enter.native="getDataList()"
          class="form-inline"
        >
          <el-form-item label="考核名称">
            <el-input v-model="query.name" placeholder="考核名称"></el-input>
          </el-form-item>
          <el-form-item label="考核状态">
            <el-input v-model="query.status" placeholder="考核状态"></el-input>
          </el-form-item>
          <el-form-item label="考核对象">
            <el-input v-model="query.obj" placeholder="考核对象"></el-input>
          </el-form-item>
          <el-form-item label="创建时间">
            <el-input
              v-model="query.creatTime"
              placeholder="创建时间"
            ></el-input>
          </el-form-item>
          <el-form-item>
            <el-button
              icon="el-icon-search"
              type="primary"
              class="marginLeft"
              @click="getDataList()"
              >检索</el-button
            >
          </el-form-item>
        </el-form>
        <div class="flex justify-between align-center margin-tb-20">
          <el-radio-group v-model="query.objType" @change="getDataList()">
            <el-radio label="PERSON">个人</el-radio>
            <el-radio label="GROUP">组</el-radio>
            <el-radio label="DEPT">机构</el-radio>
          </el-radio-group>
          <div>
            <el-button type="primary" @click="pushShow = true"
              >指标推送</el-button
            >
            <el-button type="primary">批量删除</el-button>
            <el-button type="primary">批量提交</el-button>
            <el-button
              type="primary"
              @click="
                $router.push({
                  path: '/assessment-index/template/create/detail',
                })
              "
              >创建模板</el-button
            >
            <el-button type="primary">考核模板复用</el-button>
          </div>
        </div>
        <el-table
          :data="dataList"
          v-loading="dataListLoading"
          stripe
          border
          class="avue-crud"
          height="450px"
        >
          <el-table-column
            prop=""
            label="序号"
            :formatter="nShowIndex"
          ></el-table-column>
          <el-table-column prop="name" label="考核名称"></el-table-column>
          <el-table-column prop="obj" label="考核对象"></el-table-column>
          <el-table-column prop="startTime" label="开始时间"></el-table-column>
          <el-table-column prop="endTime" label="结束时间"></el-table-column>
          <el-table-column prop="createTime" label="创建时间"></el-table-column>
          <el-table-column prop="status" label="考核状态"></el-table-column>
          <el-table-column label="操作" width="350px">
            <template slot-scope="scope">
              <el-button type="primary" plain>拆解</el-button>
              <el-button type="primary" plain>编辑</el-button>
              <el-button type="primary" plain>提交</el-button>
              <el-button type="primary" plain>驳回原因</el-button>
            </template>
          </el-table-column>
        </el-table>
        <div class="avue-crud__pagination">
          <el-pagination
            @size-change="sizeChangeHandle"
            @current-change="currentChangeHandle"
            :current-page="query.pageNo"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="query.pageSize"
            :total="totalPage"
            background
            layout="total, sizes, prev, pager, next, jumper"
          >
          </el-pagination>
        </div>
      </div>
    </basic-container>
    <push :visible.sync="pushShow" @cancel="pushShow = false" />
  </div>
</template>

<script>
import push from "@/views/assessment-index/template/create/components/push";
import { delObj } from "@/api/jiangjin/jiangjingrjcjlb";
import { mapGetters } from "vuex";
import { getJiangJinBm } from "@/api/admin/dept";
import { getAssessmentPage } from "@/api/assessment/index.js";
export default {
  data() {
    return {
      pushShow: false,
      query: {
        pageSize: 10,
        pageNo: 1,
        objType: "PERSON",
      },
      dataList: [],
      totalPage: 0,
      dataListLoading: false,
      addOrUpdateAllVisible: false,
      deptId: "", //负责部门ID
      deptName: "", //负责部门名称
    };
  },
  components: {
    push,
  },
  created() {
    this.getDataList();
  },
  mounted() {
    this.getJiangJinJg();
  },
  computed: {
    ...mapGetters(["permissions"]),
  },
  methods: {
    //获取奖金管理人机构
    getJiangJinJg() {
      getJiangJinBm().then((res) => {
        if (res.data.data != null && res.data.data.length > 0) {
          this.deptId = "";
          this.deptName = "";
          this.deptId = res.data.data[0].deptId;
          this.deptName = res.data.data[0].name;
          this.getDataList();
        } else {
          this.$notify.closeAll();
          this.$notify.error("没有相关负责部门");
          this.deptName = "无相关负责部门";
        }
      });
    },
    nShowIndex(row, column, cellValue, index) {
      return index + 1;
    },
    // 获取数据列表
    getDataList() {
      this.dataListLoading = true;
      getAssessmentPage(Object.assign(this.query)).then((response) => {
        this.dataList = response.data.data.records;
        this.totalPage = response.data.data.total;
        this.dataListLoading = false;
      });
    },
    // 每页数
    sizeChangeHandle(val) {
      this.query.pageSize = val;
      this.query.pageNo = 1;
      this.getDataList();
    },
    // 当前页
    currentChangeHandle(val) {
      this.query.pageSize = val;
      this.getDataList();
    },
    addOrUpdateAll() {
      this.addOrUpdateAllVisible = true;
    },
    // 删除
    deleteHandle(id) {
      this.$confirm("是否确认删除", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(function () {
          return delObj(id);
        })
        .then((data) => {
          this.$notify.closeAll();
          this.$notify.success("删除成功");
          this.getDataList();
        });
    },
  },
};
</script>


<style scoped>
</style>